package cn.edu.nwsuaf.teachercenter.service.impl;

import java.util.List;

import org.hibernate.Hibernate;
import org.springframework.stereotype.Service;

import cn.edu.nwsuaf.teachercenter.pojo.CourceEmployee;
import cn.edu.nwsuaf.teachercenter.service.CourceEmployeeService;

@Service(value="courceEmployeeService")
public class CourceEmployeeServiceImpl extends BaseServiceImpl<CourceEmployee> implements CourceEmployeeService {

	@Override
	public List<CourceEmployee> searchCourceEmployee(String teacherNo) {
		// TODO Auto-generated method stub
		String hql = "FROM CourceEmployee as employee where employee.teacher.teacherNo=?";
		String[] param = {teacherNo};
		List<CourceEmployee> list = super.findAll(hql,param);
		for(CourceEmployee c:list){
			Hibernate.initialize(c.getSclass());
			Hibernate.initialize(c.getCource());
			Hibernate.initialize(c.getTeacher());
		}
		return list;
	}

	@Override
	public List<CourceEmployee> loadMyClass(String teacherNo) {
		// TODO Auto-generated method stub
		String hql = "FROM CourceEmployee as employee where employee.teacher.teacherNo=?";
		String[] param = {teacherNo};
		List<CourceEmployee> list = super.findAll(hql,param);
		for(CourceEmployee c:list){
			Hibernate.initialize(c.getSclass());
		}
		return list;
	}

	@Override
	public List<CourceEmployee> loadMyCource(String teacherNo) {
		// TODO Auto-generated method stub
		String hql = "FROM CourceEmployee as employee where employee.teacher.teacherNo=?";
		String[] param = {teacherNo};
		List<CourceEmployee> list = super.findAll(hql,param);
		for(CourceEmployee c:list){
			Hibernate.initialize(c.getCource());
		}
		return list;
	}

}
